(function(){"use strict";BX.namespace("BX.Landing.UI.Panel");var e=BX.Landing.Utils.addClass;var t=BX.Landing.Utils.proxy;var n=BX.Landing.Utils.append;var i=BX.Landing.Utils.slice;var s=BX.Landing.Utils.clone;var a=BX.Landing.Utils.bind;var o=["A red flare silhouetted the jagged edge of a wing","I watched the storm, so beautiful yet terrific","Almost before we knew it, we had left the ground","Waves flung themselves at the blue evening","A shining crescent far beneath the flying vessel"];var r=["&#x0423;&#x0442;&#x0440;&#x0435;&#x043D;&#x043D;&#x0435;&#x0435; &#x0441;&#x043E;&#x043B;&#x043D;&#x0446;&#x0435; &#x044F;&#x0440;&#x043A;&#x043E; &#x043E;&#x0441;&#x0432;&#x0435;&#x0442;&#x0438;&#x043B;&#x043E; &#x043F;&#x043E;&#x043B;&#x044F;&#x043D;&#x0443; &#x0438; &#x043B;&#x0435;&#x0441;","&#x041F;&#x0440;&#x0438;&#x043B;&#x0435;&#x0442;&#x0435;&#x0432;&#x0448;&#x0438;&#x0435; &#x043F;&#x0442;&#x0438;&#x0446;&#x044B; &#x0437;&#x0430;&#x043D;&#x044F;&#x043B;&#x0438; &#x0432;&#x0435;&#x0441;&#x044C; &#x0441;&#x043A;&#x0430;&#x043B;&#x0438;&#x0441;&#x0442;&#x044B;&#x0439; &#x0431;&#x0435;&#x0440;&#x0435;&#x0433;","&#x0411;&#x043E;&#x0434;&#x0440;&#x044F;&#x0449;&#x0438;&#x0439; &#x043C;&#x043E;&#x0440;&#x0441;&#x043A;&#x043E;&#x0439; &#x0432;&#x043E;&#x0437;&#x0434;&#x0443;&#x0445; &#x0431;&#x044B;&#x043B; &#x043F;&#x0440;&#x043E;&#x0445;&#x043B;&#x0430;&#x0434;&#x0435;&#x043D; &#x0438; &#x0441;&#x0432;&#x0435;&#x0436;","&#x042D;&#x0442;&#x043E; &#x043B;&#x0443;&#x0447;&#x0448;&#x0435;&#x0435;, &#x0447;&#x0442;&#x043E; &#x043C;&#x043E;&#x0433;&#x043B;&#x043E; &#x0441; &#x043D;&#x0438;&#x043C; &#x043F;&#x0440;&#x043E;&#x0438;&#x0437;&#x043E;&#x0439;&#x0442;&#x0438; &#x0432; &#x043D;&#x043E;&#x0432;&#x043E;&#x043C; &#x0433;&#x043E;&#x0440;&#x043E;&#x0434;&#x0435;","&#x041D;&#x043E;&#x0432;&#x0430;&#x044F; &#x043A;&#x043D;&#x0438;&#x0433;&#x0430; &#x043E;&#x043A;&#x0430;&#x0437;&#x0430;&#x043B;&#x0430;&#x0441;&#x044C; &#x0438;&#x043D;&#x0442;&#x0435;&#x0440;&#x0435;&#x0441;&#x043D;&#x043E;&#x0439; &#x0438; &#x043F;&#x043E;&#x0437;&#x043D;&#x0430;&#x0432;&#x0430;&#x0442;&#x0435;&#x043B;&#x044C;&#x043D;&#x043E;&#x0439;"];var l="&#1576;&#1591;&#1575;&#1576;&#1593; &#1571;&#1581;&#1605;&#1585; &#1575;&#1585;&#1578;&#1587;&#1605;&#1578; &#1589;&#1608;&#1585;&#1577; &#1592;&#1604;&#1610;&#1617;&#1577; &#1604;&#1581;&#1583;&#1608;&#1583; &#1575;&#1604;&#1580;&#1606;&#1575;&#1581; &#1575;&#1604;&#1605;&#1587;&#1606;&#1606;&#1577;.";var h="&#1492;&#1496;&#1489;&#1506; &#1492;&#1488;&#1495;&#1491; &#1513;&#1500;&#1497; &#1493;&#1492;&#1496;&#1489;&#1506; &#1492;&#1488;&#1495;&#1512; &#1495;&#1500;&#1511;&#1493; &#1494;&#1497;&#1499;&#1512;&#1493;&#1503; &#1502;&#1513;&#1493;&#1514;&#1507;.";var u="&#45208;&#45716; &#54253;&#54413;&#51012; &#51648;&#53020;&#48372;&#50520;&#45796;. &#45320;&#47924;&#45208; &#50500;&#47492;&#45796;&#50864;&#47732;&#49436;&#46020; &#50628;&#52397;&#45212; &#54253;&#54413;&#51012;.";var g=new WeakSet;BX.Landing.UI.Panel.GoogleFonts=function(){BX.Landing.UI.Panel.Content.apply(this,["google-fonts-panel",{title:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_TITLE")}]);this.pangramIndex=-1;e(this.layout,"landing-ui-panel-google-fonts");e(this.overlay,"landing-ui-panel-google-fonts-overlay");this.client=new BX.Landing.Client.GoogleFonts;var t=BX.Landing.PageObject.getRootWindow();var i=t.document.body.querySelector(".landing-ui-view-container");n(this.layout,i);n(this.overlay,i);this.searchForm=this.createSearchForm();this.categoryForm=this.createCategoryForm();this.languageForm=this.createLanguageForm();n(this.searchForm.layout,this.sidebar);n(this.categoryForm.layout,this.sidebar);n(this.languageForm.layout,this.sidebar);n(this.createListLayout(),this.content);n(this.createPaginationLayout(),this.content);BX.Event.bind(this.getMoreButton(),"click",this.onMoreButtonClick.bind(this))};BX.Landing.UI.Panel.GoogleFonts.getInstance=function(){return BX.Landing.UI.Panel.GoogleFonts.instance||(BX.Landing.UI.Panel.GoogleFonts.instance=new BX.Landing.UI.Panel.GoogleFonts)};BX.Landing.UI.Panel.GoogleFonts.prototype={constructor:BX.Landing.UI.Panel.GoogleFonts,__proto__:BX.Landing.UI.Panel.Content.prototype,superclass:BX.Landing.UI.Panel.Content.prototype,createListLayout:function(){return BX.Dom.create({tag:"div",props:{classList:"landing-ui-panel-fonts-list"}})},getListLayout:function(){return this.content.querySelector(".landing-ui-panel-fonts-list")},createPaginationLayout:function(){return BX.Dom.create({tag:"div",props:{classList:"landing-ui-panel-fonts-pagination"},children:[BX.Dom.create({tag:"span",props:{className:"ui-btn ui-btn-lg ui-btn-light-border"},text:BX.Landing.Loc.getMessage("LANDING_FONTS_PANEL_MORE_BUTTON_LABEL")})]})},getMoreButton:function(){return this.getPaginationLayout().querySelector(".ui-btn")},getPaginationLayout:function(){return this.content.querySelector(".landing-ui-panel-fonts-pagination")},show:function(e){var n=this.superclass.show.call(this);n.then(function(){this.searchForm.fields[0].enableEdit();this.searchForm.fields[0].input.focus()}.bind(this));if(this.isFontsLoaded()){return n.then(t(this.saveResolver,this))}if(e){if(e["hideOverlay"]){this.overlay.style.display="none"}if(e["context"]){this.context=e["context"]}}this.page=0;BX.Dom.hide(this.getMoreButton());return n.then(function(){return this.showLoader()}.bind(this)).then(function(){return this.getFonts()}.bind(this)).then(function(e){return this.applyFilter(e)}.bind(this)).then(function(e){var t=this.paginateList(e);return this.loadFonts(t[this.page]||[])}.bind(this)).then(function(e){return this.renderList(e)}.bind(this)).then(function(){BX.Dom.show(this.getMoreButton());return this.hideLoader()}.bind(this)).then(function(){return this.saveResolver()}.bind(this))},onMoreButtonClick:function(e){e.preventDefault();this.page+=1;void this.showLoader();var t=this.getMoreButton();BX.Dom.addClass(t,"ui-btn-wait");BX.Dom.style(t,"pointer-events","none");var n=false;this.getFonts().then(function(e){return this.applyFilter(e)}.bind(this)).then(function(e){var t=this.paginateList(e);n=t.length-1<=this.page;return this.loadFonts(t[this.page]||[])}.bind(this)).then(function(e){return this.renderList(e)}.bind(this)).then(function(){BX.Dom.removeClass(this.getMoreButton(),"ui-btn-wait");BX.Dom.style(t,"pointer-events",null);if(n){BX.Dom.hide(t)}return this.hideLoader()}.bind(this))},saveResolver:function(){var e=this;return new Promise((function(t){e.resolver=t}))},getFonts:function(){if(this.response){return Promise.resolve(this.response)}return this.client.getList().then(t(this.saveResponse,this))},paginateList:function(e){var t=[];while(e.length){t.push(e.splice(0,21))}return t},saveResponse:function(e){return this.response=e},isFontsLoaded:function(){return!!this.response},showLoader:function(){if(!this.loader){this.loader=new BX.Loader({target:this.body,offset:{left:"134px",top:"-30px"}})}BX.Dom.style(this.sidebar,{transition:"200ms all ease",opacity:.8,"pointer-events":"none"});this.loader.show();return Promise.resolve()},hideLoader:function(){if(this.loader){this.loader.hide()}BX.Dom.style(this.sidebar,{transition:null,opacity:null,"pointer-events":null});return Promise.resolve()},loadFonts:function(e){var t;if(this.context){t=this.context}else{t=BX.Landing.PageObject.getRootWindow()}return new Promise((function(n){if(!BX.Type.isArrayFilled(e)){n(e)}else{WebFont.load({google:{families:e.map((function(e){return e.family.replace(/ /g,"+")}))},context:t,classes:false,active:function(){var t=BX.Landing.PageObject.getRootWindow();if(t.document.fonts){t.document.fonts.ready.then((function(){n(e)}))}else{setTimeout(n,3e3,e)}}})}}))},applyFilter:function(e){var t=this.searchForm.fields[0].getValue();var n=this.languageForm.fields[0].getValue();var i=this.categoryForm.fields[0].getValue();if(!BX.Type.isArrayFilled(i)){i=this.categoryForm.fields[0].items.map((function(e){return e.value}))}return e.filter((function(e){return n.every((function(t){return e.subsets.indexOf(t)!==-1}))&&i.some((function(t){return t===e.category}))&&(!BX.Type.isStringFilled(t)||String(e.family).toLowerCase().includes(String(t).toLowerCase()))}))},createListItem:function(e){var t=this.languageForm.fields[0].getValue();var n="";var i="ltr";var s="left";this.pangramIndex+=1;this.pangramIndex=this.pangramIndex>4?0:this.pangramIndex;if(t.includes("latin")){n=o[this.pangramIndex]}if(t.includes("cyrillic")){n=r[this.pangramIndex]}if(t.includes("arabic")){i="rtl";s="right";n=l}if(t.includes("hebrew")){i="rtl";s="right";n=h}if(t.includes("korean")){n=u}return'<div class="landing-ui-font-preview">'+'<div class="landing-ui-font-preview-font-name">'+e.family+"</div>"+'<div class="landing-ui-font-preview-font-button">'+'<span class="ui-btn ui-btn-xs ui-btn-light-border ui-btn-round">'+BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_SELECT_BUTTON")+"</span>"+"</div>"+'<div style="font-family: '+e.family+"; direction: "+i+"; text-align: "+s+';" class="landing-ui-font-preview-pangram" contenteditable="true" onpaste="return false;">'+n+"</div>"+"</div>"},onFilterChange:function(){void this.showLoader();this.page=0;var e=false;this.getFonts().then(function(e){return this.applyFilter(e)}.bind(this)).then(function(t){var n=this.paginateList(t);e=n.length<=1;return this.loadFonts(n[this.page]||[])}.bind(this)).then(function(t){this.content.scrollTop=0;void this.hideLoader();if(e){BX.Dom.hide(this.getMoreButton())}else{BX.Dom.show(this.getMoreButton())}return this.renderList(t,true)}.bind(this))},renderList:function(e,t){return this.renderItems(e,t)},renderItems:function(e,t){if(!t){this.getListLayout().insertAdjacentHTML("beforeend",e.map(this.createListItem,this).join(""))}else{if(!BX.Type.isArrayFilled(e)&&BX.Type.isStringFilled(this.searchForm.fields[0].getValue())){this.getListLayout().innerHTML="";BX.Dom.append(this.getEmptyStub(),this.getListLayout())}else{this.getListLayout().innerHTML=e.map(this.createListItem,this).join("")}}i(this.getListLayout().children).forEach(this.initItem(e),this)},getEmptyStub:function(){return BX.Dom.create({tag:"div",props:{className:"landing-ui-fonts-panel-empty-stub"},text:BX.Landing.Loc.getMessage("LANDING_FONTS_PANEL_EMPTY_STUB")})},initItem:function(e){return function(t,n){if(!g.has(t)){const a=t.querySelector(".landing-ui-font-preview-font-button");BX.Event.bind(a,"click",this.onFontSelect.bind(this,e[n-this.page*21]));g.add(t);var i=t.querySelector(".landing-ui-font-preview-pangram");if(i){var s=i.innerText;BX.Event.bind(i,"blur",(function(){if(!BX.Type.isStringFilled(i.innerText)){i.innerText=s}}))}}}},getListItems:function(){return i(this.content.querySelectorAll(".landing-ui-font-preview.cell"))},createSearchForm:function(){var e=BX.Runtime.debounce(this.onFilterChange,500,this);return new BX.Landing.UI.Form.StyleForm({title:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_SEARCH_TITLE"),fields:[new BX.Landing.UI.Field.Text({selector:"searchQuery",textOnly:true,onValueChange:function(){void this.showLoader();e()}.bind(this),placeholder:BX.Loc.getMessage("LANDING_GOOGLE_FONT_SEARCH_PLACEHOLDER")})]})},createLanguageForm:function(){var e=new BX.Landing.UI.Form.StyleForm({title:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_LANGUAGE_FORM_TITLE")});var n=new BX.Landing.UI.Factory.FieldFactory({onValueChange:t(this.onFilterChange,this)});var i=window.location.host.includes(".ru");e.addField(n.create({type:"radio",items:[{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_LANGUAGE_CYRILLIC"),value:"cyrillic",checked:i},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_LANGUAGE_LATIN"),value:"latin",checked:!i},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_LANGUAGE_ARABIC"),value:"arabic"},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_LANGUAGE_HEBREW"),value:"hebrew"},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_LANGUAGE_KOREAN"),value:"korean"}]}));return e},createCategoryForm:function(){var e=new BX.Landing.UI.Form.StyleForm({title:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_CATEGORY_FORM_TITLE")});var n=new BX.Landing.UI.Factory.FieldFactory({onValueChange:t(this.onFilterChange,this)});e.addField(n.create({type:"checkbox",items:[{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_CATEGORY_SANS_SERIF_2"),value:"sans-serif"},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_CATEGORY_SERIF_2"),value:"serif"},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_CATEGORY_DISPLAY"),value:"display"},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_CATEGORY_HANDWRITING"),value:"handwriting"},{name:BX.Landing.Loc.getMessage("LANDING_GOOGLE_FONT_PANEL_CATEGORY_MONOSPACE"),value:"monospace"}]}));return e},onFontSelect:function(e){this.selectedFont=e;this.onApply()},onApply:function(){if(this.resolver){var e=s(this.selectedFont);e.subset=this.languageForm.fields[0].getValue();this.hide().then(this.resolver.bind(null,e))}},onCancel:function(){this.hide()}}})();
//# sourceMappingURL=google_fonts_panel.map.js